/*
 * MIT License
 *
 * Copyright (c) 2025 Mark·虎
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

package com.hsxxherp.key.support.file;

import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

/**
 * 文件存储服务接口，提供文件上传、下载和删除的基本操作
 *
 * @author Mark·虎（2486970363@qq.com）
 */
public interface IFileStorageService {

    /**
     * 上传文件
     *
     * @param file 要上传的文件，使用 Spring 的 MultipartFile 类型
     * @return 文件存储后的唯一标识或访问路径，方便后续下载和管理
     * @throws IOException 上传过程中可能出现的 IO 异常
     */
    String uploadFile(MultipartFile file) throws IOException;

    /**
     * 下载文件
     *
     * @param fileId 文件的唯一标识或访问路径，用于定位要下载的文件
     * @return 包含文件内容的输入流，可用于读取文件数据
     * @throws IOException 下载过程中可能出现的 IO 异常
     */
    InputStream downloadFile(String fileId) throws IOException;

    /**
     * 删除文件
     *
     * @param fileId 文件的唯一标识或访问路径，用于定位要删除的文件
     * @throws IOException 删除过程中可能出现的 IO 异常
     */
    void deleteFile(String fileId) throws IOException;
}